home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume8 / roff_bl < prev    next >
Encoding:
Text File  |  1989-09-23  |  4.5 KB  |  147 lines

  1. Newsgroups: comp.sources.misc
  2. subject: v08i048: roff (simple script to include filters & macros in document text)
  3. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  4. Reply-To: brian@decwrl.dec.com@apt.UUCP
  5.  
  6. Posting-number: Volume 8, Issue 48
  7. Submitted-by: brian@decwrl.dec.com@apt.UUCP
  8. Archive-name: roff_bl
  9.  
  10. This script allows you to include a comment at the beginning of your
  11. troff documents which tells this script what filters and macros to
  12. run the document through before sending it to troff.
  13.  
  14. <>  Brian Litzinger @ APT Technology Inc., San Jose, CA
  15. <>  UUCP:  {apple,sun,pyramid}!daver!apt!brian    brian@apt.UUCP
  16. <>  VOICE: 408 370 9077      FAX: 408 370 9291
  17.  
  18. #! /bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of shell archive."
  25. # Contents:  README Portability roff
  26. # Wrapped by brian@apt on Wed Sep 20 13:15:36 1989
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'README' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'README'\"
  30. else
  31. echo shar: Extracting \"'README'\" \(1420 characters\)
  32. sed "s/^X//" >'README' <<'END_OF_FILE'
  33. Xroff is a script that allows you to encode the filters that a troff
  34. Xfile must be passed through along with which macro packages to use
  35. Xin the document file.
  36. X
  37. XTo use roff you simply add a roff command line as the first line of
  38. Xyour document file.  Then when you wish to print out the document
  39. Xyou can simply enter
  40. X
  41. X    roff filename
  42. X
  43. Xroff will generate the correct command stream to print the file.
  44. X
  45. Xthe roff command line is basically a line of text that is passed to
  46. Xeval(1).  Its format is as follows:
  47. X
  48. X\" exec tbl | pic | eroff -mm
  49. X
  50. Xthe '\"' is a troff/nroff comment delimeter.  The 'exec' helps identify
  51. Xthis line as a roff command line.
  52. X
  53. Xthe rest of the line is the filters, packages, and macros that the
  54. Xdocument file should be passed through.  Other examples are:
  55. X
  56. X\" exec eroff
  57. X
  58. X\" exec tbl | eroff -mm -mapt
  59. X
  60. XIf you look at the roff script you will notice that we strip off the
  61. Xfirst line of the document file (the roff command line) before we
  62. Xpipe the document through the rest of the filters.  At first glance
  63. Xone might think this isn't necessary, but the mm macros are in my
  64. Xopinion broke, or at least the ones we have are.  If the very first
  65. Xphysical line of the document isn't .PH "''''" you get the header.
  66. XEven if the first line is simply a comment, like the roff command line.
  67. X
  68. XYou might also notice a reference to '$F'.  This is necessary for us
  69. Xto be compatible with an older roff command line format.
  70. END_OF_FILE
  71. if test 1420 -ne `wc -c <'README'`; then
  72.     echo shar: \"'README'\" unpacked with wrong size!
  73. fi
  74. # end of 'README'
  75. fi
  76. if test -f 'Portability' -a "${1}" != "-c" ; then 
  77.   echo shar: Will not clobber existing file \"'Portability'\"
  78. else
  79. echo shar: Extracting \"'Portability'\" \(266 characters\)
  80. sed "s/^X//" >'Portability' <<'END_OF_FILE'
  81. XPortability Concerns:
  82. X
  83. Xroff uses head(1).  I've heard some UNIXes don't have head. sigh...
  84. X
  85. Xwe use eroff, you will probably want to change the second line of
  86. Xroff from eroff to troff, and change the examples appropriately.
  87. X
  88. Xroff was written on a System V system.  
  89. X
  90. END_OF_FILE
  91. if test 266 -ne `wc -c <'Portability'`; then
  92.     echo shar: \"'Portability'\" unpacked with wrong size!
  93. fi
  94. # end of 'Portability'
  95. fi
  96. if test -f 'roff' -a "${1}" != "-c" ; then 
  97.   echo shar: Will not clobber existing file \"'roff'\"
  98. else
  99. echo shar: Extracting \"'roff'\" \(599 characters\)
  100. sed "s/^X//" >'roff' <<'END_OF_FILE'
  101. X# roff by Brian E. Litzinger
  102. XTROFF=eroff
  103. XTMP=/tmp/roff$$
  104. Xfor file in $*
  105. Xdo
  106. X    case $file in
  107. X    -*)
  108. X        args="$args $file"
  109. X    ;;
  110. X    *)
  111. X        command_line="`head -1 $file`"
  112. X        b="`echo $command_line | cut -c1-8`"
  113. X        if [ "$b" != '\" exec ' ] ; then
  114. X        echo "$file not roff format file!"
  115. X        exit 2
  116. X        fi
  117. X        command="`echo $command_line | cut -c9- `"
  118. X        d="sed -e '1d' $file |"
  119. X        for i in $command ; do
  120. X        if [ "$i" = '$F' ] ; then
  121. X            true
  122. X        else
  123. X            if [ "$i" = "$TROFF" ] ; then
  124. X            d="$d $i $args"
  125. X            else
  126. X            d="$d $i"
  127. X            fi
  128. X        fi
  129. X        done
  130. X        #echo $d
  131. X        eval $d
  132. X    ;;
  133. X    esac
  134. Xdone
  135. END_OF_FILE
  136. if test 599 -ne `wc -c <'roff'`; then
  137.     echo shar: \"'roff'\" unpacked with wrong size!
  138. fi
  139. chmod +x 'roff'
  140. # end of 'roff'
  141. fi
  142. echo shar: End of shell archive.
  143. exit 0
  144.  
  145.  
  146.  
  147.